package o;

import com.huawei.hms.framework.network.restclient.hwhttp.HttpContants;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import javax.annotation.Nullable;

public final class fus {
    final boolean ʻ;
    @Nullable
    private volatile fuc ʼ;
    final Map<Class<?>, Object> ˊ;
    @Nullable
    final fuw ˋ;
    final fui ˎ;
    final fur ˏ;
    final String ॱ;
    final ArrayList<InetAddress> ᐝ;

    public static class a {
        boolean ʼ;
        Map<Class<?>, Object> ˊ;
        @Nullable
        fuw ˋ;
        @Nullable
        fur ˎ;
        o.fui.a ˏ;
        String ॱ;
        ArrayList<InetAddress> ॱॱ;

        public a() {
            this.ˊ = Collections.emptyMap();
            this.ʼ = false;
            this.ॱॱ = new ArrayList();
            this.ॱ = HttpContants.HTTP_METHOD_GET;
            this.ˏ = new o.fui.a();
        }

        a(fus o_fus) {
            Map emptyMap;
            this.ˊ = Collections.emptyMap();
            this.ʼ = false;
            this.ॱॱ = new ArrayList();
            this.ˎ = o_fus.ˏ;
            this.ॱ = o_fus.ॱ;
            this.ˋ = o_fus.ˋ;
            if (o_fus.ˊ.isEmpty()) {
                emptyMap = Collections.emptyMap();
            } else {
                emptyMap = new LinkedHashMap(o_fus.ˊ);
            }
            this.ˊ = emptyMap;
            this.ˏ = o_fus.ˎ.ˎ();
            this.ʼ = o_fus.ʻ;
            this.ॱॱ = o_fus.ᐝ;
        }

        public a ˊ(fur o_fur) {
            if (o_fur == null) {
                throw new NullPointerException("url == null");
            }
            this.ˎ = o_fur;
            return this;
        }

        public a ˎ(String str) {
            if (str == null) {
                throw new NullPointerException("url == null");
            }
            if (str.regionMatches(true, 0, "ws:", 0, 3)) {
                str = "http:" + str.substring(3);
            } else {
                if (str.regionMatches(true, 0, "wss:", 0, 4)) {
                    str = "https:" + str.substring(4);
                }
            }
            return ˊ(fur.ॱॱ(str));
        }

        public a ॱ(String str, String str2) {
            this.ˏ.ˎ(str, str2);
            return this;
        }

        public a ˋ(String str, String str2) {
            this.ˏ.ˊ(str, str2);
            return this;
        }

        public a ˏ(String str) {
            this.ˏ.ˎ(str);
            return this;
        }

        public a ˏ(fui o_fui) {
            this.ˏ = o_fui.ˎ();
            return this;
        }

        public a ˏ(fuc o_fuc) {
            String o_fuc2 = o_fuc.toString();
            if (o_fuc2.isEmpty()) {
                return ˏ("Cache-Control");
            }
            return ॱ("Cache-Control", o_fuc2);
        }

        public a ˋ(fuw o_fuw) {
            return ˎ("POST", o_fuw);
        }

        public a ˊ(fuw o_fuw) {
            return ˎ("PUT", o_fuw);
        }

        public a ˎ(String str, @Nullable fuw o_fuw) {
            if (str == null) {
                throw new NullPointerException("method == null");
            } else if (str.length() == 0) {
                throw new IllegalArgumentException("method.length() == 0");
            } else if (o_fuw != null && !fvt.ˏ(str)) {
                throw new IllegalArgumentException("method " + str + " must not have a request body.");
            } else if (o_fuw == null && fvt.ˋ(str)) {
                throw new IllegalArgumentException("method " + str + " must have a request body.");
            } else {
                this.ॱ = str;
                this.ˋ = o_fuw;
                return this;
            }
        }

        public a ˋ(boolean z) {
            this.ʼ = z;
            return this;
        }

        public a ˊ(ArrayList<String> arrayList) throws UnknownHostException {
            if (arrayList == null) {
                throw new IllegalArgumentException("additionalIpAddresses is null");
            }
            Iterator it = arrayList.iterator();
            while (it.hasNext()) {
                ॱ((String) it.next());
            }
            return this;
        }

        public a ॱ(String str) throws UnknownHostException {
            if (str == null) {
                throw new IllegalArgumentException("IP address is null");
            }
            try {
                for (Object add : InetAddress.getAllByName(str)) {
                    this.ॱॱ.add(add);
                }
                return this;
            } catch (Throwable e) {
                UnknownHostException unknownHostException = new UnknownHostException("Broken system behaviour for dns lookup of " + str);
                unknownHostException.initCause(e);
                throw unknownHostException;
            }
        }

        public fus ॱ() {
            if (this.ˎ != null) {
                return new fus(this);
            }
            throw new IllegalStateException("url == null");
        }
    }

    fus(a aVar) {
        this.ˏ = aVar.ˎ;
        this.ॱ = aVar.ॱ;
        this.ˎ = aVar.ˏ.ˊ();
        this.ˋ = aVar.ˋ;
        this.ˊ = fvg.ˎ(aVar.ˊ);
        this.ʻ = aVar.ʼ;
        this.ᐝ = aVar.ॱॱ;
    }

    public fur ˏ() {
        return this.ˏ;
    }

    public String ˋ() {
        return this.ॱ;
    }

    public fui ॱ() {
        return this.ˎ;
    }

    @Nullable
    public String ˋ(String str) {
        return this.ˎ.ॱ(str);
    }

    public List<String> ˏ(String str) {
        return this.ˎ.ˎ(str);
    }

    @Nullable
    public fuw ˎ() {
        return this.ˋ;
    }

    public boolean ˊ() {
        return this.ʻ;
    }

    public ArrayList<InetAddress> ʻ() {
        return this.ᐝ;
    }

    public a ʽ() {
        return new a(this);
    }

    public fuc ᐝ() {
        fuc o_fuc = this.ʼ;
        if (o_fuc != null) {
            return o_fuc;
        }
        o_fuc = fuc.ˏ(this.ˎ);
        this.ʼ = o_fuc;
        return o_fuc;
    }

    public boolean ॱॱ() {
        return this.ˏ.ˎ();
    }

    public boolean ʼ() {
        return ˋ("Http2ConnectionIndex") != null;
    }

    public String toString() {
        return "Request{method=" + this.ॱ + ", url=" + this.ˏ + ", tags=" + this.ˊ + '}';
    }
}
